﻿package code {
	
	public class Flipper extends GameObject {
		private const ROTATION_AMOUNT = Math.PI / 6;
		public var rotated:Boolean;
		private var mass:Number = 10;
		private var omega:Number;
		// creates a flipper
		public function Flipper(shapeType:String, radius:Number, sides:Number, color:uint, thickness:Number, hollow:Boolean, angle:Number = 0, lineHeight:int = 0) {
			super(shapeType, radius, sides, color, thickness, hollow, angle, lineHeight);
			rotated = false;
			omega = -.1
		}
		
		public function rotateFlipper(angle:Number){
			trace(shape.angle);
			//if(!rotated){
				if(shape.angle > angle){
					shape.graphics.clear();
					shape.angle += omega;
					shape.rotateVertices();
					shape.renderVertices();
					
					shape.linesArray = new Array();
					
					createLinesArray();
				}
				rotated = true;
			//}
		}
		
		public function rotateFlipperBack(angle:Number){
			if(shape.angle < angle && !rotated){
				shape.graphics.clear();
				shape.angle -= omega;
				shape.rotateVertices();
				shape.renderVertices();
				
				shape.linesArray = new Array();
				createLinesArray();
			}
		}
		
		// returns the current intertia of the bar
		public function getInertia(leverArmDisplacement:Number):Number{
			return ((2 /3) * mass * Math.pow(leverArmDisplacement, 2));
		}

	}
	
}
